{% extends "common.html" %}


{% block subtitle_main %}
{% url 'new_view' as new_url %}
    <h3>{{localnav.name}}</h3>
    <ul>
        {% for key, value in subtitle_lists.items %}
            {%if key == local_news_type %}
                <li class="active"><a href="{{new_url}}?news_type={{key}}&nav_id={{localnav.id}}" target="_self">{{value}}</a></li>
            {%else%}
                <li><a href="{{new_url}}?news_type={{key}}&nav_id={{localnav.id}}" target="_self">{{value}}</a></li>
            {%endif%}
        {% endfor %}
              {%block subtitle%} {% endblock %}
    </ul>
{% endblock %}



{% block subtitle_local %}
    <div class="c-m-t-path pull-right">当前位置：{{localnav.name}} > {{local_news_value}} • 摩力顿</div>
    <h4>{{localnav.name}}</h4>
{% endblock %}


{% block subtitle_content %}

<div class="c-m-list">
{% for news in page_obj %}
   {% if news.img.img %}
        <div class="c-m-l-first hover_box">
            <div class="c-m-l-f-left pull-left">
                <img src="{{news.img.img.url}}" title="{{news.title}}" alt="{{news.title}}"/>
            </div>
            <div class="c-m-l-f-right pull-right">
                <h4>{{news.title}}</h4>
                {% autoescape off %}
                    <p>{{news.content| striptags | slice:"150"}}</p>
                {%endautoescape%}
                <span>{{news.pub_time | date:"Y-m-d H:i" }}</span>
                <div class="public-button">
                    <a href="{% url 'new_details' news.id %}?nav_id={{localnav.id}}" target="_self">查看详情</a>
                </div>
            </div>
        </div>
    {%else%}
            <li>
                <div class="c-m-l-data pull-left">
                    <span>{{news.pub_time | date:"H" }}</span>
                    <span>{{news.pub_time | date:"Y-m-d" }}</span>
                </div>
                <div class="c-m-l-main pull-right">
                    <a href="{% url 'new_details' news.id %}?nav_id={{localnav.id}}" target="_self">
                        <h4>{{news.title}}</h4>
                    {% autoescape off %}
                        <p>{{news.content | striptags | slice:"150"}}</p>
                    {%endautoescape%}
                    </a>
                </div>
            </li>
    {%endif%}
{% endfor %}

   <div class="c-m-l-pagination">
        <ul>
            <li>共{{paginator.num_pages}}页记录</li>

            {% if page_obj.has_previous %}
                <li><a href="{{ request.path }}?&page={{ page_obj.previous_page_number }}" target="_self">上一页</a></li>
            {%else%}
                <li><a href="#" target="_self">上一页</a></li>
            {% endif %}

            {%for num in page_obj.paginator.page_range %}
                {%if num == page_obj.number %}
                    <li class="active"><a href="#" target="_self">{{num}}</a></li>
                {%else%}
                    <li><a href="{{ request.path }}?page={{ num }}&nav_id={{localnav.id}}" target="_self">{{num}}</a></li>
                {%endif%}
            {%endfor%}

            {% if page_obj.has_next %}
               <li> <a href="{{ request.path }}?page={{ page_obj.next_page_number }}&nav_id={{localnav.id}}" target="_self">下一页</a></li>
            {%else%}
               <li> <a href="#" target="_self">下一页</a></li>
            {% endif %}

        </ul>
    </div>
{% endblock %}
